package cz.proks.simplecalendarmanager.server;

import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import java.util.logging.Logger;

public class Configuration {			
	private static Configuration INSTANCE; 
	
	private final Properties properties;
	
	private final Logger log = Logger.getLogger(getClass().getSimpleName());
	
	private Configuration() {
		log.info("Configuration():: start");
		this.properties = new Properties();
		
		try {
			properties.load(new FileInputStream(System.getProperty("simplecalendarmanager.configuration.file")));
		} catch(IOException ioex) {
			throw new RuntimeException(ioex);
		}
		
		log.info("Configuration():: exit");
	}
	
	private Properties getProperties() {
		return properties;
	}
	
	public static void load() {
		INSTANCE = new Configuration();				
	}		
	
	public static String getHomeUrl() {
		return INSTANCE.getProperties().getProperty("homeUrl");
	}
	
	public static String getApplicationName() {
		return INSTANCE.getProperties().getProperty("applicationName");
	}
	
	public static String getConsumerToken() {
		return INSTANCE.getProperties().getProperty("consumerToken");
	}
	
	public static String getConsumerTokenSecret() {
		return INSTANCE.getProperties().getProperty("consumerTokenSecret");
	}
}
